<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:action name="header" executeResult="true">
	<s:param name="titles">Chi tiết đơn đặt hàng</s:param>
</s:action>

<s:action name="managesidebar" executeResult="true" />

<!-- Center -->
<div id="center_column_des" class="center_column">

<div class="breadcrumb">
	<a href="<s:url action="index"></s:url>">Trang chủ</a><span class="navigation-pipe">&gt;</span><span class="navigation_page">Chi tiết đơn đặt hàng</span>
</div>

<!-- /Breadcrumb -->
		<fieldset>
			<h3>Thông tin đơn hàng</h3>
			<table class="form">
				<tr>
					<td>Tên người nhận :</td>
					<td><s:property value="%{oneBill.full_name}"/></td>
				</tr>				
				<tr>
					<td>Công ty :</td>
					<td><s:property value="%{oneBill.company}"/></td>
				</tr>
				<tr>
					<td>Địa chỉ :</td>
					<td><s:property value="%{oneBill.address}"/></td>
				</tr>
				<tr>
					<td>Thành phố :</td>
					<td><s:property value="%{oneBill.city_name}"/></td>
				</tr>
				<tr>
					<td>Số điện thoại :</td>
					<td><s:property value="%{oneBill.phone}"/></td>
				</tr>
				<tr>
					<td>Ghi chú :</td>
					<td><s:property value="%{oneBill.comment}"/></td>
				</tr>
				<tr>
					<td>Trạng thái đơn hàng :</td>
					<td><s:if test="oneBill.accepted==1">Chờ duyệt</s:if><s:elseif test="oneBill.accepted==2">Hoàn thành</s:elseif><s:else>Bị hủy</s:else></td>
				</tr>
			</table>
		</fieldset>
		<div id="order-detail-content" class="table_block">
			<table id="cart_summary" class="std">
				<thead>
					<tr>
						<th class="cart_product first_item">Sản phẩm</th>
						<th class="cart_description item" colspan="3">Mô tả</th>
						<th class="cart_unit item">Đơn giá</th>
						<th class="cart_quantity item">Số lượng</th>
						<th class="cart_total last_item">Tổng cộng</th>
					</tr>
				</thead>
				<tfoot>
					<tr class="cart_total_price">
						<td colspan="6">Tổng tiền :</td>
						<td class="price" id="total_price"><span class="price"><s:property value="total" /> VNĐ</span>
						</td>
					</tr>
				</tfoot>
				<tbody>
					<s:iterator value="billDetailList" var="bill">
					<tr class="cart_item">
						<td class="cart_product">
							<a href="<s:url action="detail"><s:param name="pid" value="#bill.product_id" /></s:url>"><img src="<s:property value="#bill.product_image" />" width="45"></a>
						</td>
						<td class="cart_description" colspan="3">
							<h5>
								<a class="product_link" href="<s:url action="detail"><s:param name="pid" value="#bill.product_id" /></s:url>"><s:property value="#bill.product_name" /></a>
							</h5>
						</td>
						<td class="cart_unit">
							<span class="price"> <s:property value="#bill.price" /> VNĐ </span>
						</td>
						<td class="cart_quantity">
							<span class="price"> <s:property value="#bill.qty" /> </span>
						</td>
						<td class="cart_total">
							<span class="price" id="total" > <s:property value="#bill.qty*#bill.price" /> VNĐ</span>
						</td>
					</tr>
					</s:iterator>
				</tbody>
			</table>		
		</div>
		<form action="<s:url action="viewbill"></s:url>" method="post" class="std" enctype="multipart/form-data" id="actionF">
			<p class="submit" style="padding:10px 0 0 150px;">
			<s:if test="oneBill.accepted==1">
				<input onclick="if(confirm('Bạn có chắc đã hoàn thành đơn đặt hàng này không?')){actionF(<s:property value="oneBill.bill_id" />,'finish');}return false;" type="button" 
					value="Hoàn thành đơn hàng" class="button_large" style="float:left;">
			
				<input onclick="if(confirm('Bạn có chắc muốn hủy đơn đặt hàng này không?')){actionF(<s:property value="oneBill.bill_id" />,'cancel');}return false;" type="button" 
					value="Huỷ đơn hàng" class="exclusive" style="float:left;">
			</s:if>
			</p>
			<s:hidden id="sid" name="sid" value="%{sid}"></s:hidden>
			<s:hidden id="saction" name="saction" value="process"></s:hidden>
		</form>
	
<script type="text/javascript">
function actionF(slideId,action){
	var pidVal = $("#sid");
	var pactionVal = $("#saction");
	var editorVal = $("#actionF");
	var finishUrl = '<s:url action="viewbill"></s:url>';
	var cancelUrl = '<s:url action="viewbill"></s:url>';
	pidVal.val(slideId);
	if(action == "finish"){
		pactionVal.val("finish");
		editorVal.attr("action", finishUrl);
	}else{
		pactionVal.val("cancel");
		editorVal.attr("action", cancelUrl);
	}
	
	editorVal.submit();
}

</script>
</div>

<s:action name="footer" executeResult="true" />